package com.wh1200.mybatis.xmlless.model.dto

import com.wh1200.mybatis.xmlless.annotations.XmllessMethod
import com.wh1200.mybatis.xmlless.enums.QueryType
import com.wh1200.mybatis.xmlless.model.base.BaseXmllessMethodWrapper

/**
 * @author 吴昊
 * @date 2024/01/17
 * @version 1.0
 * @since v4.0.0
 */
class DefaultXmllessMethodWrapper(
    private val xmllessMethod: XmllessMethod?
) : BaseXmllessMethodWrapper {

  override fun getType(): QueryType? {
    return xmllessMethod?.type
  }

  override fun getSorts(): List<String> {
    return xmllessMethod?.sortBy?.toList() ?: listOf()
  }

  override fun getConditions(): List<String> {
    return xmllessMethod?.conditions?.toList() ?: emptyList()
  }

  override fun getUpdateSetList(): List<String> {
    return xmllessMethod?.updateSet?.toList() ?: emptyList()
  }

  override fun getGroupBys(): List<String> {
    return xmllessMethod?.groupBy?.toList() ?: listOf()
  }

  override fun getScriptAppend(): String {
    return xmllessMethod?.scriptAppend ?: ""
  }

  override fun getJoinAppend(): String {
    return xmllessMethod?.joinAppend ?: ""
  }

  override fun getWhereAppend(): String {
    return xmllessMethod?.whereAppend ?: ""
  }

  override fun getIncludesInner(): List<String> {
    return xmllessMethod?.includes?.toList() ?: listOf()
  }

  override fun getExcludes(): List<String> {
    return xmllessMethod?.excludes?.toList() ?: listOf()
  }

  override fun getLimit(): String? {
    return xmllessMethod?.limit
  }

}
